/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Frédéric
 */
public class Location {
    
    private int id_location;
    private Client client;
    private Vehicule vehicule;
    private int indexKilometriqueDepart;
    private Date dateDebutLocation;
    private int Test;

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Date getDateDebutLocation() {
        return dateDebutLocation;
    }

    public void setDateDebutLocation(Date dateDebutLocation) {
        this.dateDebutLocation = dateDebutLocation;
    }

    public int getId_location() {
        return id_location;
    }

    public void setId_location(int id_location) {
        this.id_location = id_location;
    }

    public int getIndexKilometriqueDepart() {
        return indexKilometriqueDepart;
    }

    public void setIndexKilometriqueDepart(int indexKilometriqueDepart) {
        this.indexKilometriqueDepart = indexKilometriqueDepart;
    }

    public Vehicule getVehicule() {
        return vehicule;
    }

    public void setVehicule(Vehicule vehicule) {
        this.vehicule = vehicule;
    }

    public Location(int id_location, Client client, Vehicule vehicule, int indexKilometriqueDepart, Date dateDebutLocation) {
        this.id_location = id_location;
        this.client = client;
        this.vehicule = vehicule;
        this.indexKilometriqueDepart = indexKilometriqueDepart;
        this.dateDebutLocation = dateDebutLocation;
    }
    
    public double calculeCoutLocation() {
        
        int nombreKmParcouru = this.getVehicule().getIndexKilometrique() - this.getIndexKilometriqueDepart();
        
        double coutKilometriqueTotal = nombreKmParcouru * this.getVehicule().calculeCoutKm();
               
        int nombreJour = this.getDateDebutLocation().differenceNombreDeJoursAujourdhui();
        
        double coutJourTotal = nombreJour * this.getVehicule().calculeCoutJour();
        
        return (coutKilometriqueTotal + coutJourTotal) * 
                    (1 - (this.getClient().getReductionAccordee()/100d));
        
        
    }
    
}
